package com.mitaotao._1_语法._3_分支._1_数值交换;

public class _03_数值交换_数学运算法 {
    public static void main(String[] args) {
        //数学运算法，如果数值较大容易超出int范围
        int num1 = 2;
        int num2 = 3;
        int sum;
        System.out.println("数值交换之前num1为："+num1);
        System.out.println("数值交换之前num2为："+num2);

        sum = num1 + num2;
        num1 = sum - num1;
        num2 = sum - num2;
        System.out.println("数值交换之后num1为："+num1);
        System.out.println("数值交换之后num2为："+num2);
    }
}
